package com.shu.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class FileUtils {

	/**
	 * 追加文件内容
	 * @param file
	 * @param conent
	 */
	public static void writeFile(File file, String conent) {
		BufferedWriter out = null;
		try {
			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
			out.write(conent + "\r\n");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static String readFile(File file) {
		 try {
			String content = org.apache.commons.io.FileUtils.readFileToString(file,"UTF8");
			return content;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}  
	}
	
}
